Skip to content

fix(plan,admin): monitors/API keys stop with the plan; admin stats and avatars - #131

Merged
Darknode-Official merged 1 commit into
mainfrom
fix/audit-plan-admin
Nov 23, 2026
Merged

Darknode-Official merged 1 commit into
mainfrom
fix/audit-plan-admin

Conversation

@Darknode-Official

Copy link
Copy Markdown
Owner

From the 2026-11-20 bug audit (#5 and #6).

#5: monitors and API keys kept working after a downgrade

  • Monitors: each monitor now records who set it up (by). Every scheduled (alarm) run re-reads that person's live plan with the service account, including a team owner's shared plan (new liveTier in worker/plan-share.js).
    • If the plan no longer covers monitoring, the run is held. A history row says why, and the card shows a Held: plan pill.
    • The next check waits a full interval, so the alarm doesn't loop.
  • Resuming a paused monitor (pause with paused:false) now needs the plan, like upsert, run and test. The resumer then carries the check.
  • API keys: keys record their creator. Ingest returns 402 once the creator no longer has Team.
    • Read-back, list, revoke and drain stay open, so a downgraded account can still clean up.
  • Older monitors and keys that have no recorded creator fall back to the workspace owner: the personal workspace's own user, or a team workspace's createdBy.
  • Fail-open: if the plan can't be read (Firestore error, no service account), the work continues. A blip never stops paid work or breaks CI.

#6: admin panel

  • "New users (7 days)", the registration chart and last-active now handle the Auth metadata date string that ensureUserDoc stores. Before, every real profile counted as 0.
  • Avatars load only from lh*.googleusercontent.com / avatars.githubusercontent.com, with referrerpolicy="no-referrer". Any other user-set photoURL falls back to initials, so opening Admin > Users no longer sends the owner's IP to a server the user chose.

Tests

14 new tests:

  • liveTier: service-account read, downgrade, admin, legacy fallback, shared plan, fail-open
  • monitor hold and resume, plus the alarm() path
  • ingest 402, read-back still open, fail-open

npm test: 5050 passed, 0 failed.

Not deployed. Shipping needs a Worker deploy (wrangler) as well as hosting.

…user stats and avatars

- Monitors record who set them up; each scheduled run re-reads that person's
  live plan (service account, plan sharing included) and is held, with a
  history entry and a "Held: plan" pill, when it no longer covers monitoring.
  Resuming a paused monitor now needs the plan. Unreadable plans fail open.
- API keys record their creator; ingest is refused with 402 once the creator
  no longer has Team. Read-back, list, revoke and drain stay open.
- Admin: "New users (7 days)", the registration chart and last-active now
  count the Auth metadata date strings profiles store.
- Admin: avatars load only from Google/GitHub avatar hosts, with
  no-referrer, so a user-set photoURL can't make the owner's browser call an
  arbitrary server.
@Darknode-Official
Darknode-Official merged commit bacfd8b into main Nov 23, 2026
10 checks passed
@Darknode-Official
Darknode-Official deleted the fix/audit-plan-admin branch November 23, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant